/// @tags: DivGraph
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>

using namespace std;

namespace BlueQuantum {

int const N = 1e4 + 5;

int cnt, diff[N], sp, ans[N];
bool dis[N], vis[N], e[N];
vector<int> g[N], id[N];

void solve(int u) {
  vis[u] = true;
  for (size_t i = 0, v; i < g[u].size(); ++i)
    if (!vis[v = g[u][i]]) {
      dis[v] = dis[u] ^ 1;
      e[id[u][i]] = true;
      solve(v);
    } else if (!e[id[u][i]]) {
      e[id[u][i]] = true;
      if (dis[u] == dis[v]) {
        cnt++, diff[u]++, diff[v]--;
        sp = id[u][i];
      } else
        diff[u]--, diff[v]++;
    }
}

void dfs(int u) {
  vis[u] = true;
  for (size_t i = 0, v; i < g[u].size(); ++i)
    if (!vis[v = g[u][i]]) {
      dfs(v);
      if (diff[v] == cnt) ans[++*ans] = id[u][i];
      diff[u] += diff[v];
    }
}

inline int main() {
  int n, m;
  cin >> n >> m;
  for (int i = 1, u, v; i <= m; ++i) {
    cin >> u >> v;
    g[u].push_back(v);
    id[u].push_back(i);
    g[v].push_back(u);
    id[v].push_back(i);
  }
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) solve(i);
  if (!cnt) {
    cout << m << '\n';
    for (int i = 1; i <= m; ++i) cout << i << ' ';
    return 0;
  }
  memset(vis, 0, sizeof(vis));
  for (int i = 1; i <= n; ++i)
    if (!vis[i]) dfs(i);
  if (cnt == 1) ans[++*ans] = sp;
  cout << *ans << '\n';
  sort(ans + 1, ans + *ans + 1);
  for (int i = 1; i <= *ans; ++i) cout << ans[i] << ' ';
  return 0;
}

}  // namespace BlueQuantum

int main() {
#ifndef ONLINE_JUDGE
#ifdef LOCAL
  freopen("/tmp/CodeTmp/testdata.in", "r", stdin);
  freopen("/tmp/CodeTmp/testdata.out", "w", stdout);
#else
  freopen("CF19E Fairy.in", "r", stdin);
  freopen("CF19E Fairy.out", "w", stdout);
#endif
#endif

  ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  return BlueQuantum::main();
}
